﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace System.Web.Mvc
{
    public static class GetUrls
    {
        public enum EnumAvatarSizeType
        {
            Large,
            Small
        }
        public static MvcHtmlString GetAvatar(this HtmlHelper htmlHelper, string avatarUrl, EnumAvatarSizeType sizeType)
        {
            if (avatarUrl == null)
            {
                return new MvcHtmlString("");
            }
            switch (sizeType)
            {
                case EnumAvatarSizeType.Large:
                    return new MvcHtmlString( avatarUrl.Replace("Original", "Large"));
                case EnumAvatarSizeType.Small:
                    return new MvcHtmlString( avatarUrl.Replace("Original", "Small"));
            }
            return new MvcHtmlString(avatarUrl);
        }

        public static string GetFolderPath(string avatarUrl)
        {
            if (avatarUrl == null || avatarUrl == "")
            {
                return "";
            }
            int lstIndex = avatarUrl.LastIndexOf('/');
            return avatarUrl.Substring(0,lstIndex).Replace('/','\\');
        }
    }
}